#include "daywidget.h"
#include "ui_daywidget.h"

DayWidget::DayWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DayWidget)
{
    ui->setupUi(this);
    setSelected(false);
    setMonType(0);
    setIndex(-1);
    ui->lab_Day->installEventFilter(this);
    ui->lab_Hint->installEventFilter(this);
}

DayWidget::~DayWidget()
{
    delete ui;
}

void DayWidget::setDay(int nDay)
{
    ui->lab_Day->setText(QString("%1").arg(nDay));
}

int DayWidget::getDay()
{
    return ui->lab_Day->text().toInt();
}

void DayWidget::setHint(const QString &strHint)
{
    ui->lab_Hint->setText(strHint);
}

QString DayWidget::getHint()
{
    return ui->lab_Hint->text();
}

void DayWidget::setSelected(bool selected)
{
    bSelected = selected;
}

bool DayWidget::getSelected() const
{
    return bSelected;
}

void DayWidget::setIndex(int index)
{
     nIndex = index;
}

int DayWidget::getIndex()
{
    return nIndex;
}

void DayWidget::setMonType(int monType)
{
    nMonType = monType;
}

int DayWidget::getMonType() const
{
    return nMonType;
}


bool DayWidget::eventFilter(QObject *pObj, QEvent *pEvent)
{
//    if(pObj == ui->lab_Day || pObj == ui->lab_Hint)
//    {
        if(pEvent->type() == QEvent::MouseButtonPress)
            emit signalMouseDoubleClick(bSelected, nIndex, nMonType);
   // }
}

void DayWidget::paintEvent(QPaintEvent *)
{
     QStyleOption opt;
     opt.init(this);
     QPainter p(this);
     style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
